package com.qk.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qk.common.PageResult;
import com.qk.dto.CustomerQueryDTO;
import com.qk.entity.Customer;
import com.qk.mapper.CustomerMapper;
import com.qk.service.CustomerService;
import org.springframework.stereotype.Service;

/**
 * @author 28188
 */
@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
    @Override
    public PageResult<Customer> pageCustomers(CustomerQueryDTO customerQueryDTO) {
        // 创建 MyBatis-Plus 分页对象
        Page<Customer> page = new Page<>(customerQueryDTO.getPage(), customerQueryDTO.getPageSize());

        Page<Customer> result = this.baseMapper.selectListCustomer(page, customerQueryDTO);

        return new PageResult<>(result.getTotal(), result.getRecords());
    }
}
